Add features test to cardo doc tests
authorGleb Kozyrev <gleb@gkoz.com>
Sat, 10 Oct 2015 14:20:21 +0000 (17:20 +0300)
committerGleb Kozyrev <gleb@gkoz.com>
Sat, 10 Oct 2015 15:10:28 +0000 (18:10 +0300)
tests/test_cargo_doc.rs

index 935178379785dca91d563d7fa4bfccb6afe5f129..232be534c2d2f4023e40b7bebcf9b96ec1382bd9 100644 (file)
@@ -477,3 +477,46 @@ test!(doc_multiple_deps {
     assert_that(&p.root().join("target/doc/bar/index.html"), existing_file());
     assert_that(&p.root().join("target/doc/baz/index.html"), existing_file());
 });
+
+test!(features {
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [package]
+            name = "foo"
+            version = "0.0.1"
+            authors = []
+
+            [dependencies.bar]
+            path = "bar"
+
+            [features]
+            foo = ["bar/bar"]
+        "#)
+        .file("src/lib.rs", r#"
+            #[cfg(feature = "foo")]
+            pub fn foo() {}
+        "#)
+        .file("bar/Cargo.toml", r#"
+            [package]
+            name = "bar"
+            version = "0.0.1"
+            authors = []
+
+            [features]
+            bar = []
+        "#)
+        .file("bar/build.rs", r#"
+            fn main() {
+                println!("cargo:rustc-cfg=bar");
+            }
+        "#)
+        .file("bar/src/lib.rs", r#"
+            #[cfg(feature = "bar")]
+            pub fn bar() {}
+        "#);
+    assert_that(p.cargo_process("doc").arg("--features").arg("foo"),
+                execs().with_status(0));
+    assert_that(&p.root().join("target/doc"), existing_dir());
+    assert_that(&p.root().join("target/doc/foo/fn.foo.html"), existing_file());
+    assert_that(&p.root().join("target/doc/bar/fn.bar.html"), existing_file());
+});